package whf.framework.workflow.engine;

import whf.framework.exception.DAOException;
import whf.framework.exception.ServiceNotFoundException;
import whf.framework.meta.MetaFactory;
import whf.framework.util.BeanFactory;
import whf.framework.util.Utils;
import whf.framework.workflow.entity.WorkflowEntity;

/**
 * @author King
 *
 */
@SuppressWarnings("unchecked")
public class WorkflowEntityService {
	public static void saveWorkflowEntity(WorkflowEntity entity) throws DAOException, ServiceNotFoundException {
		BeanFactory.getService(MetaFactory.findByModelClass(entity.getClass())).update(entity);
	}
	
	public static WorkflowEntity findWorkflowEntity(String entityName, long id) throws DAOException, ServiceNotFoundException {
		return (WorkflowEntity)BeanFactory.getService(MetaFactory.findByModelClass(Utils.getClassByClassName(entityName))).findByPrimaryKey(id);
	}
}
